﻿ 
<%@ page contentType="text/html; charset=UTF-8" %>
<div class="searchBar">
用户帐号：<input id="s_user_name" name="s_user_name" type="text" class="box-input">&nbsp;&nbsp;
<input id="s_user" type="button" class="btns" value="查  询">
</div>

<table id="user_resetpass_grid"></table>      
<div id="user_resetpass_page"></div>  
 


<script>
 
	jQuery("#user_resetpass_grid").jqGrid({//列表
        datatype: "json", 
        hidegrid: false, //不显示收缩
        url:'system/User/list.do',
        height:usergridHeight,
        forceFit: true,//调整宽度不改变表格宽度
        width: usergridWidth,
        colNames:[
        '编号'
        ,'账号'
        ,'密码'
        ,'真实姓名'
        ,'性别'
        ,'所属机构ID'
        ,'所属机构'
        ,'工作电话'
        ,'手机号1'
        ,'手机号2'
        ,'传真'
        ,'生日'
        ,'生日1'
        ,'电子邮件'
        ,'家庭住址'
        ,'邮编'
        ,'身份证'
        ,'禁用'
        ,'开通时间'
        ,'最后登录时间'
        ,'登录次数'
        ,'角色'
	    ],
        colModel:[
        {name:'id',index:'id', width:2,sorttype:'int',sortable:false}  
        ,{name:'name',index:'name',width:100,sortable:false}
        ,{name:'password',index:'password',width:2,sortable:false}
        ,{name:'realname',index:'realname',width:100,sortable:false}
        ,{name:'sex',index:'sex',width:2,sortable:false}
        ,{name:'company',index:'company',width:2,sortable:false}
        ,{name:'companyName',index:'companyName',width:140,sortable:false}
        ,{name:'worktel',index:'worktel',width:100,sortable:false}
        ,{name:'mobiletel1',index:'mobiletel1',width:100,sortable:false}
        ,{name:'mobiletel2',index:'mobiletel2',width:2,sortable:false}
        ,{name:'fax',index:'fax',width:2,sortable:false}
        ,{name:'birthday',index:'birthday',width:2,sortable:false}
        ,{name:'birthdayString',index:'birthdayString',width:2,sortable:false}
        ,{name:'email',index:'email',width:2,sortable:false}
        ,{name:'address',index:'address',width:2,sortable:false}
        ,{name:'postalcode',index:'postalcode',width:2,sortable:false}
        ,{name:'idcard',index:'idcard',width:2,sortable:false}
        ,{name:'blocked',index:'blocked',width:90,sortable:false,formatter:fun_user_formatBlocked}
        ,{name:'regdateString',index:'regdateString',width:140,sortable:false,sorttype:'date',datefmt:'y-m-d h:m:s'}
        ,{name:'lastloginDateString',index:'lastloginDateString',width:2,sortable:false}
        ,{name:'logincount',index:'logincount',width:2,sortable:false}
        ,{name:'roleIds',index:'roleIds',width:2,sortable:false}
        ],
        multiselect: false,//禁止多选
        toolbar:[true,'top'],
        rowNum:10, 
        rowList:[5,10,20], 
        viewrecords: true, 
        sortname:  "id" , //默认排序的列名    //sortorder: "desc", 
        pager: '#user_resetpass_page', 
        jsonReader: {     
          root: 'dataRows',   
          repeatitems : false     
        }
    })
    
    $("#t_user_resetpass_grid").append("<div style='width:30%;' class='l'>个人管理->密码重置列表</div><div class='r text-r' style='width:60%; height:28px'>"
       +"<a href='javascript:void(0)' onclick=\"fun_user_resetdate()\" class='modify r'>密码重置</a></div>");//列表头
        
       
    $("#t_user_resetpass_grid").removeClass("ui-userdata ui-state-default"); //删样式
    $("#t_user_resetpass_grid").addClass("ui-title ui-corner-top ui-helper-clearfix");//加样式

    jQuery("#user_resetpass_grid").jqGrid('hideCol',['id','password','company','sex','mobiletel2','fax','birthday','birthdayString','email','address','postalcode','idcard','lastloginDateString','logincount','roleIds']);//隐藏列
    $("#user_resetpass_grid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' });//隐藏横向滚动条
    
    function fun_user_formatBlocked(cellvalue, options, rowObject){
        if(rowObject.blocked==1){
            return ("正常");
        }else if(rowObject.blocked==2){
            return ("开通");
        }else if(rowObject.blocked==4){
            return ("暂停");
        }else{
            return ("停止");
        }
    }
    
      
     
     function fun_user_resetdate(){//重置操作
        var id =$("#user_resetpass_grid").jqGrid('getGridParam','selrow');
        var dataUpdate = $("#user_resetpass_grid").jqGrid('getGridParam','selarrrow');//'selrow'     
        var lengthUpdate=dataUpdate.length;
        if(lengthUpdate >1){
  	        alertmsg("每次只能修改一条记录!","alert");
  	        return;
  	    }
        if(typeof(id) =="string"){
            rowData=jQuery("#user_resetpass_grid").jqGrid('getRowData',id);  
		    
		    
		    confirm("确认要重置"+rowData.realname+"的密码吗？", user_resetdate_submit);  
        }else{
           alertmsg("请至少选择一条记录再操作!","alert");
        }


         
	}
	 
     function  user_resetdate_submit(){//重置提交 
     	 
         var userid=rowData.id;  
         $.ajax({
             type: "POST",
             url:"system/User/resetPassword.do",
             data:{
            	 useridJson:userid
             },
             dataType: "json",
             success:function(json){
                 if(json.success){
                     $("#user_resetpass_grid").trigger("reloadGrid");
                     alertmsg(json.msg,"info");
                 }else{
                     alertmsg(json.msg,"alert");
                 }
                 
             }
        })
     }
      
	
	  
	function userupDialogHeight(){//弹出层高度
        if($.browser.mozilla){//火狐
           return 374;
	    }else{//其它
		   return 366;
	    }
    }
	
    function useraddDialogHeight(){//弹出层高度
        if($.browser.mozilla){//火狐
           return 344;
	    }else{//其它
		   return 336;
	    }
    }

	function fun_usergridResize(){
	    jQuery("#user_resetpass_grid").setGridHeight(mDiv.height-195);
        jQuery("#user_resetpass_grid").setGridWidth(mDiv.width-22);
	} 
	
	$("#westDiv").bind("pageResize",function(event){
		 fun_usergridResize();
	})
	
	function usergridWidth(){    
        mDiv.width-22; 
    }
    
    function usergridHeight(){    
        mDiv.height-195;
    }
	
	fun_usergridResize();
	
	$('#s_user').click(function(){
         var s_name=encodeURI($('#s_user_name').val());
         $("#user_resetpass_grid").setGridParam({url:'system/User/list.do?s_name='+s_name});
         $("#user_resetpass_grid").trigger("reloadGrid");
    })
    
      

</script>
